package com.mdoffice.servlet;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.mdoffice.dao.impl.PatientDAOImpl;
import com.mdoffice.dao.interfaces.PatientDAO;

public class PatientList extends HttpServlet {
	/**
	 * Constructor of the object.
	 */
	public PatientList() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession();
		try {
			PatientDAO pdao = new PatientDAOImpl();
			List l = pdao.selectAllPatient();
			session.setAttribute("allpatientlist", l);
			response.sendRedirect("./AllPatientList.jsp");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			response.sendRedirect("./fail.jsp");
		}
	}

	public void init() throws ServletException {
		// Put your code here
	}
}